﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="辅料挂帐.aspx.cs" Inherits="syc.Sale.辅料挂帐" %>
<head>
    <title></title>
</head>
<body>

    <script type="text/javascript" language="javascript" src="/common.js"></script>

    <link rel="stylesheet" href="jquery.checkbox.css" />
    <link rel="stylesheet" href="jquery.safari-checkbox.css" />

    <script type="text/javascript" src="jquery.js"></script>

    <script type="text/javascript" src="jquery.checkbox.min.js"></script>

    <script type="text/javascript" language="javascript" src="/common.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $('input:checkbox:not([safari])').checkbox();
            $('input[safari]:checkbox').checkbox({ cls: 'jquery-safari-checkbox' });
            $('input:radio').checkbox();
        });
						
</script>

    <form id="form1" runat="server">
    <asp:Label ID="SelectedID" runat="server" Text="" Visible="false"></asp:Label>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
        OnSelected="SqlDataSource1_Selected" UpdateCommand="UPDATE [采购材料合同]
SET [是否完成] = @是否完成
WHERE [采购材料合同].[ID]=@ID" DeleteCommand="delete 材料发票记录 where ID=@ID">
        <UpdateParameters>
            <asp:Parameter Name="是否完成" Type="Boolean" />
            <asp:Parameter Name="ID" Type="Int32" />
        </UpdateParameters>
        <DeleteParameters>
            <asp:Parameter Name="ID" Type="Int32" />
        </DeleteParameters>
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
        SelectCommand="select 0 as ID,'全部' as 名称 union SELECT [ID], [名称] FROM [材料供货单位] where 是否是辅料=1">
    </asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:SCMConnectionString1 %>"
        SelectCommand="select ID=0,品名='全部' union SELECT [ID], [品名] as 品名 FROM [材料]">
    </asp:SqlDataSource>
    <div id="wintop" class="wintop">
        采购材料发票查询</div>
    <asp:Panel ID="Panel1" runat="server" CssClass="panel">
    <input type="button" value="录 入" class="button" onclick="parent.swin2_load('/sale/材料到货发票登记.aspx',600,420);"/>   
    <asp:Button ID="Button_Edit" runat="server" Text="修 改" CssClass="button" 
            UseSubmitBehavior="False" />
    <asp:Button ID="Button_Delete" runat="server" Text="删 除" CssClass="button"  
        UseSubmitBehavior="False" 
        OnClientClick="if(!confirm('确认要删除该条记录吗？'))return(false);" onclick="Button_Delete_Click" 
       />
</asp:Panel>
    <asp:Panel ID="Panel2" runat="server" CssClass="panel" GroupingText="采购材料发票查询">
        <span style="display: inline-block; width: 90px; text-align: right;">供货单位：</span><asp:DropDownList
            ID="GongHuo" runat="server" Width="120" DataSourceID="SqlDataSource2" DataTextField="名称"
            DataValueField="ID">
        </asp:DropDownList>
        <span style="margin-left: 30px;">&nbsp;&nbsp;&nbsp; </span>材料类别：<asp:DropDownList
            ID="LeiBie" runat="server" Width="140px" DataSourceID="SqlDataSource3" DataTextField="品名"
            DataValueField="ID">
        </asp:DropDownList>
        <br />
        <span style="display: inline-block; width: 90px; text-align: right;">年度 ：</span><asp:DropDownList
            ID="NianDu" runat="server" Width="120" Style="margin-left: 1px" AutoPostBack="true"
            OnSelectedIndexChanged="NianDu_SelectedIndexChanged">
            <asp:ListItem Value="0">全部</asp:ListItem>
            <asp:ListItem Value="2008">2008</asp:ListItem>
            <asp:ListItem Value="2009">2009</asp:ListItem>
            <asp:ListItem Value="2010">2010</asp:ListItem>
            <asp:ListItem Value="2011">2011</asp:ListItem>
            <asp:ListItem Value="2012">2012</asp:ListItem>
            <asp:ListItem Value="2013">2013</asp:ListItem>
            <asp:ListItem Value="2014">2014</asp:ListItem>
            <asp:ListItem Value="2015">2015</asp:ListItem>
            <asp:ListItem Value="2016">2016</asp:ListItem>
            <asp:ListItem Value="2017">2017</asp:ListItem>
            <asp:ListItem Value="2018">2018</asp:ListItem>
            <asp:ListItem Value="2019">2019</asp:ListItem>
            <asp:ListItem Value="2020">2020</asp:ListItem>
        </asp:DropDownList>
        <span style="margin-left: 75px;"></span>季度：</span><asp:DropDownList AutoPostBack="true"
            ID="JiDu" runat="server" Width="80" OnSelectedIndexChanged="JiDu_SelectedIndexChanged">
            <asp:ListItem Value="0">全部</asp:ListItem>
            <asp:ListItem Value="1">1 季度</asp:ListItem>
            <asp:ListItem Value="2">2 季度</asp:ListItem>
            <asp:ListItem Value="3">3 季度</asp:ListItem>
            <asp:ListItem Value="4">4 季度</asp:ListItem>
        </asp:DropDownList>
        <br />
        <span style="margin-left: 20px;"></span>开始日期：<asp:TextBox ID="Date1" runat="server"
            CssClass="intxt1" Width="110px"></asp:TextBox>
        <img align="middle" alt="" onclick="makecalendar(document.getElementById('Date1').value, document.getElementById('Date1'));"
            src="/Icons/29.png" />
        <span style="margin-left: 32px;"></span>结束日期：<asp:TextBox ID="Date2" runat="server"
            CssClass="intxt1" Width="120px"></asp:TextBox><img align="middle" alt="" onclick="makecalendar(document.getElementById('Date2').value, document.getElementById('Date2'));"
                src="/Icons/29.png" />
        <span style="display: inline-block; width: 20px; text-align: right;"></span>
        <asp:Button ID="Button_Query" runat="server" Text="查 询" UseSubmitBehavior="false"
            CssClass="mbutton" OnClick="Button_Query_Click" />
        <asp:Button ID="Button_Reset" runat="server" Text="清空条件" UseSubmitBehavior="false"
            CssClass="mbutton"  />
    
    </asp:Panel>
  
   <asp:Panel ID="Panel3" runat="server" CssClass="panel2">
            <asp:Label ID="Message" runat="server" Text="·准备就绪" CssClass="prompt"></asp:Label>
   </asp:Panel>
    <div class="gridframe">
        <div class="gridview">
            <table border="1" width="100%" cellspacing="0" cellpadding="0" bordercolor="#e5cfab">
                <tr>
		           <td class="grid-title"><div style="float:left;margin-top:3px;">材料采购合同</div><div style="float:right;">
                    <asp:DropDownList ID="PageSizeOption" runat="server" AutoPostBack="True" 
                        onselectedindexchanged="PageSizeOption_SelectedIndexChanged">
                    <asp:ListItem Value="10" >10 项/页</asp:ListItem>
                    <asp:ListItem Value="20" Selected="True">20 项/页</asp:ListItem>
                    <asp:ListItem Value="30">30 项/页</asp:ListItem>
                    <asp:ListItem Value="50">50 项/页</asp:ListItem>
                    <asp:ListItem Value="100">100 项/页</asp:ListItem>
                    </asp:DropDownList>
                    <div>
                    </div>
	            </td>		          
		        </tr>
                <tr>
                    <td class="grid-back">
                        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                            CssClass="grid" DataKeyNames="ID" DataSourceID="SqlDataSource1" 
                            GridLines="None" OnDataBound="GridView1_DataBound" UseAccessibleHeader="False"
                            PageSize="20"  OnSelectedIndexChanged="GridView1_SelectedIndexChanged">
                              
                            <PagerSettings Visible="False" />
                            <RowStyle CssClass="grid-row-normal" />
                            <Columns>
                                <asp:TemplateField HeaderText="">
                                    <ItemTemplate>
                                        <asp:Button ID="Button_xz" runat="server" CommandName="Select" Text="选择" CssClass="hide" />
                                        <img src="/Icons/online.gif" style="margin-top: 2px;" alt="" />
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="Center" Width="20px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="年度" SortExpression="年度">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_nd" runat="server" Text='<%# Eval("年度") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="季度" SortExpression="季度">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_jd" runat="server" Text='<%# Eval("季度") %>'></asp:Label>
                                        季度
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="合同编号" SortExpression="合同编号">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_bh" runat="server" Text='<%# Eval("合同编号") %>'></asp:Label>                                     
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="50px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="供货单位" SortExpression="名称">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_gh" runat="server" Text='<%# Eval("名称") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="材料类别" SortExpression="品名">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_lb" runat="server" Text='<%# Eval("品名") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="110px" />
                                </asp:TemplateField>                               
                                <asp:TemplateField HeaderText="规格">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_gg" runat="server" Text='<%# Eval("规格") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="单位">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_dw" runat="server" Text='<%# Eval("单位") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="80px" />
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="发票量" SortExpression="发票量">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_sl" runat="server" Text='<%# Eval("发票量") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                                </asp:TemplateField>
                                
                                 <asp:TemplateField HeaderText="单价" SortExpression="单价">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_dj" runat="server" Text='<%# Eval("单价") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                                </asp:TemplateField>
                                
                                 <asp:TemplateField HeaderText="金额" SortExpression="金额">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_je" runat="server" Text='<%# Eval("金额") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="right" Width="70px" />
                                </asp:TemplateField>
                               
                                <asp:TemplateField HeaderText="开票日期" SortExpression="开票日期">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_rq" runat="server" Text='<%# Eval("开票日期","{0:d}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="70px" />
                                </asp:TemplateField>
                                
                                <asp:TemplateField HeaderText="挂帐日期" SortExpression="挂帐日期">
                                    <ItemTemplate>
                                        <asp:Label ID="Label_gzrq" runat="server" Text='<%# Eval("挂帐日期","{0:d}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <HeaderStyle CssClass="grid-header" />
                                    <ItemStyle CssClass="grid" HorizontalAlign="center" Width="70px" />
                                </asp:TemplateField>
                            </Columns>
                            <SelectedRowStyle CssClass="grid-row-selected" />
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table width="100%">
	                    <tr>
	                        <td class="pagebar">
                                <asp:Button ID="Button_Pager_First" UseSubmitBehavior="false" runat="server" Text="" ToolTip="首页" 
                                    CssClass="pageturn-first-b" onclick="Pager_Click" CommandName="--" />
                                <asp:Button ID="Button_Pager_Prev" UseSubmitBehavior="false" runat="server" Text="" ToolTip="上一页" 
                                    CssClass="pageturn-prev-b" onclick="Pager_Click" CommandName="-" />
                                <input type="button" class="page-split" UseSubmitBehavior="false" disabled />第<asp:TextBox 
                                    ID="TextBox_Pager" AutoPostBack="True" runat="server" CssClass="pageturn" 
                                    ontextchanged="Pager_Click"></asp:TextBox>页<input type="button" class="page-split" disabled /><asp:Label ID="Label_Pages" UseSubmitBehavior="false" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                                
                                <asp:Button ID="Button_Pager_Next" UseSubmitBehavior="false" runat="server" Text="" ToolTip="下一页" 
                                    CssClass="pageturn-next-b" onclick="Pager_Click" CommandName="+" />
                                <asp:Button ID="Button_Pager_Last" UseSubmitBehavior="false" runat="server" Text="" ToolTip="末页" 
                                    CssClass="pageturn-last-b" onclick="Pager_Click" CommandName="++" /><asp:Label ID="Label9" runat="server"></asp:Label><input type="button" class="page-split" disabled />
                            </td>
                            <td class="pagebar" align="right">
                                <asp:Label ID="Label_Total" runat="server"></asp:Label>
                            </td>
                        </tr>
                   </table>
                    </td>
                </tr>
            </table>
        </div>
    </div>
    </form>

    <script>


        var textboxs = document.getElementsByTagName("input");
        var i;
        for (i = 0; i < textboxs.length; i++) {
            if (textboxs[i].className == "textbox") {
                //textboxs[i].onchange = function(e) { this.className = "textbox-changed"; };
                textboxs[i].onfocus = function(e) { this.select(); };
            }
            else if (textboxs[i].className == "pageturn" || textboxs[i].className == "intxt1" || textboxs[i].className == "intxt2") {
                textboxs[i].onfocus = function(e) { this.select(); };
            }
        }
        setTimeout("document.getElementById('ShuLiang').focus();", 100);

        var rows = document.getElementsByTagName("tr");
        for (i = 0; i < rows.length; i++) {

            if (rows[i].className == "grid-row-normal") {
                rows[i].onmouseover = function() { this.className = "grid-row-bright"; };
                rows[i].onmouseout = function() { this.className = "grid-row-normal"; };
                rows[i].onclick = selectRow;
            }
            else if (rows[i].className == "grid-row-selected") {

            }
        }


        document.onkeydown = function(e) {
            if (!e) e = window.event;
            var tag = e.srcElement;
            if (!tag) tag = e.target;
            if (tag.tagName != "INPUT" || tag.className != "textbox") return;
            if (tag.id == "BeiZhu") return;
            if (e.keyCode == 13) e.keyCode = 9;
        }
        var rows = document.getElementById("GridView1").rows;
        var sum1 = 0,sum2=0;
        var col = 0;      
        for (i = 1; i < rows.length; i++) {
            sum1 += Number(rows[i].cells[col + 8].innerText);  
            sum2 += Number(rows[i].cells[col + 10].innerText);   
        }
        var total = document.getElementById("Label_Total");
        total.innerHTML += " </br>本页小计（发票量：" + fixFloatZ(sum1, 3) + " 吨    金额:"+ fixFloatZ(sum2, 2) + " 元）";
        parent.hidesubmenu(false);
    </script>

</body>
</html>

